# -*- coding: utf-8 -*-

# from mtcnn.base_function import *
import numpy as np
import cv2
from mtcnn.mtcnn import mtcnn
import math
import time
 
if __name__ == "__main__":
    
    m_mtcnn = mtcnn()

    print ("Load model end!!!")
    image_name = "./timg.jpg"
    bounding_boxes, points = m_mtcnn.detect_face(image_name)

    time_start=time.time();
    for i in xrange(100):
        bounding_boxes, points = m_mtcnn.detect_face(image_name)
        draw = cv2.imread(image_name)

        if type(bounding_boxes) is np.ndarray:
            nrof_faces = bounding_boxes.shape[0]
            print('Total %d face(s) detected' % (nrof_faces))
            for i in xrange(nrof_faces):
                c_box    = bounding_boxes[i]
                c_points = points[:,i]
                cv2.rectangle(draw, (c_box[0],c_box[1]), (c_box[2],c_box[3]), (0, 255, 0), 3) 
                print c_box
                print c_points
                print "*********************************************"
        else:
            print('No face detected')
    time_end=time.time();
    print (time_end-time_start)
    print "s"
    exit()

